package org.flyby.component;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.IAjaxIndicatorAware;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.markup.html.form.Form;

public abstract class FlybyIndicatingAjaxSubmitLink extends AjaxSubmitLink implements IAjaxIndicatorAware {

    public FlybyIndicatingAjaxSubmitLink(String id) {
        super(id);
    }

    protected FlybyIndicatingAjaxSubmitLink(String id, Form<?> form) {
        super(id, form);
    }

    @Override
    public String getAjaxIndicatorMarkupId() {
        return "loadingIndicator";
    }

    @Override
    protected void onError(AjaxRequestTarget target, Form<?> form) {
        super.onError(target, form);
        target.add(((FlybyPage) getPage()).getFeedbackPanel());
    }
}
